package com.junxonline.instant.common.exception;

import com.junxonline.instant.common.enumeration.ApiErrorEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * Api业务异常类
 *
 * @author JunX
 * @date 2021-06-25
 */
@Data
@EqualsAndHashCode(callSuper = false)
@AllArgsConstructor
public class ApiBizException extends RuntimeException implements Serializable {

    /**
     * 异常码
     */
    private Integer code;

    /**
     * 异常信息
     */
    private String msg;

    public ApiBizException(ApiErrorEnum apiErrorEnum) {
        super(apiErrorEnum.getMsg());
        this.code = apiErrorEnum.getCode();
        this.msg = apiErrorEnum.getMsg();
    }

    @Override
    public synchronized Throwable fillInStackTrace() {
        return super.fillInStackTrace();
    }

}
